package cn.edu.jsu.nrs.model;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import cn.edu.jsu.nrs.model.NewsType;
import cn.edu.jsu.nrs.model.Reply;

/**
 * TbNews entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tb_news", catalog = "db_nrs")
public class News implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer newsId;
	private NewsType tbNewsType;
	private String title;
	private String content;
	private String keyWord;
	private Integer clickCount;
	private Timestamp modiferTime;
	private Timestamp publishTime;
	private Set<Reply> tbReplies = new HashSet<Reply>(0);

	/** default constructor */
	public News() {
	}

	public News(Integer newsId, String title) {
		this.newsId = newsId;
		this.title = title;
	}
	
	
	

	// public News(Integer newsId,String title,String content,Date publishTime){
	// this.newsId=newsId;
	// this.title=title;
	// this.content=content;
	// this.publishTime=publishTime;
	// }

	// public News(Integer newsId,String title,String content,String
	// keyWord,Integer clickCount,Date modiferTime,Date publishTime){
	// this.newsId=newsId;
	// this.title=title;
	// //this.content=content.trim().substring(0, 15)+" ...";
	// this.content=content;
	// this.keyWord=keyWord;
	// this.clickCount=clickCount;
	// this.modiferTime=modiferTime;
	// this.publishTime=publishTime;
	// }

	/** minimal constructor */
	public News(NewsType tbNewsType, String title, String content) {
		this.tbNewsType = tbNewsType;
		this.title = title;
		this.content = content;
	}

	/** full constructor */
	public News(NewsType tbNewsType, String title, String content,
			String keyWord, Integer clickCount, Timestamp modiferTime,
			Timestamp publishTime, Set<Reply> tbReplies) {
		this.tbNewsType = tbNewsType;
		this.title = title;
		this.content = content;
		this.keyWord = keyWord;
		this.clickCount = clickCount;
		this.modiferTime = modiferTime;
		this.publishTime = publishTime;
		this.tbReplies = tbReplies;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "news_id", unique = true, nullable = false)
	public Integer getNewsId() {
		return this.newsId;
	}

	public void setNewsId(Integer newsId) {
		this.newsId = newsId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "type_id", nullable = false)
	public NewsType getTbNewsType() {
		return this.tbNewsType;
	}

	public void setTbNewsType(NewsType tbNewsType) {
		this.tbNewsType = tbNewsType;
	}

	@Column(name = "title", nullable = false)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "content", nullable = false, length = 16777215)
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name = "keyWord")
	public String getKeyWord() {
		return this.keyWord;
	}

	public void setKeyWord(String keyWord) {
		this.keyWord = keyWord;
	}

	@Column(name = "clickCount")
	public Integer getClickCount() {
		return this.clickCount;
	}

	public void setClickCount(Integer clickCount) {
		this.clickCount = clickCount;
	}

	@Column(name = "modiferTime", length = 19)
	public Timestamp getModiferTime() {
		return this.modiferTime;
	}

	public void setModiferTime(Timestamp modiferTime) {
		this.modiferTime = modiferTime;
	}

	@Column(name = "publishTime", length = 19)
	public Timestamp getPublishTime() {
		return this.publishTime;
	}

	public void setPublishTime(Timestamp publishTime) {
		this.publishTime = publishTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbNews")
	public Set<Reply> getTbReplies() {
		return this.tbReplies;
	}

	public void setTbReplies(Set<Reply> tbReplies) {
		this.tbReplies = tbReplies;
	}
}